﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace OPMS_V1.DOL
{
    public class ListArea
    {
        private const String connString = "server=localhost;database=OPMS;Integrated Security=SSPI";
        SqlConnection conn = new SqlConnection(connString);

        public DataSet retrieveDistrictArea(string selectedDistricts)
        {
            string[] tempArray;

            tempArray = selectedDistricts.Split(',');

            DataSet datafinal = new DataSet();
            
            for (int i = 0; i < tempArray.Length; i++)
            {
                DataSet data = null;
                SqlDataAdapter da = null;
                SqlCommand command=null;
                command = new SqlCommand("ListDistrictAreas", conn);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@districtname", SqlDbType.VarChar).Value = tempArray[i].Trim();
                da = new SqlDataAdapter(command);
                //Filling the DataSet with the List of Area Information
                data = new DataSet();                
                da.Fill(data);

                datafinal.Merge(data, true);
            }
            return datafinal;
        }
    }
}
